package com.tom.architect.party5.day37.simple3;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import com.tom.architect.R;

/**
 * 实现协议 UserInfoContract.UserInfoView 里面的方法
 */
public class MainActivity37 extends AppCompatActivity
        implements UserInfoContract.UserInfoView {
    private TextView mTvTextResult;
    private UserInfoPresenter mPresenter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3700);

        mTvTextResult = findViewById(R.id.text_result);
        mPresenter = new UserInfoPresenter();
        mPresenter.attach(this); // 绑定
        mPresenter.getUsers("token"); // 调用Presenter的方法，获取用户数据
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.detach(); // 解绑
    }

    @Override
    public void onLoading() {
    }

    @Override
    public void onError() {
    }

    @Override
    public void onSucceed(UserInfo userInfo) {
        mTvTextResult.setText(userInfo.toString());

    }
}